local skel = fk.CreateSkill {
  name = "efengqi__dufu",
  tags = {Skill.Lord},
}

Fk:loadTranslationTable{
  ["efengqi__dufu"] = "独夫",
  [":efengqi__dufu"] = "主公技，杀死非汉势力角色的奖惩改为摸三张牌；汉势力角色每回合首次造成伤害后，可以与你各摸一张牌。",
  ["#efengqi__dufu-draw"] = "独夫:你可以与 %src 各摸一张牌",

  ["$efengqi__dufu1"] = "顺我者昌，逆我者亡！",
  ["$efengqi__dufu2"] = "哈哈哈哈！",
}

skel:addEffect(fk.BuryVictim, {
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(skel.name) then
      return data.damage and data.damage.from == player and target.kingdom ~= "han" and target.rest == 0
        and not (data.extra_data and data.extra_data.skip_reward_punish)
    end
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    -- 跳过奖惩并摸三张……
    data.extra_data = data.extra_data or {}
    data.extra_data.skip_reward_punish = true
    player:drawCards(3, skel.name)
  end
})

skel:addEffect(fk.Damage, {
  anim_type = "drawcard",
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(skel.name) then
      if target and target.kingdom == "han" and not target.dead then
        local damageEvent = player.room.logic:getActualDamageEvents(1, function(e) return e.data.from == target end)[1]
        return damageEvent and damageEvent.data == data
      end
    end
  end,
  on_cost = function(self, event, target, player, data)
    return player.room:askToSkillInvoke(target, { skill_name = skel.name, prompt = "#efengqi__dufu-draw:"..player.id })
  end,
  on_use = function(self, event, target, player, data)
    target:drawCards(1, skel.name)
    if not player.dead then
      player:drawCards(1, skel.name)
    end
  end
})

return skel
